//
// Created by richard on 2019-01-21.
//

#include "SimSensorInPlc.h"

SimSensorInPlc::SimSensorInPlc(uint16_t value, int timeStep,
        uint16_t *output_addr, uint8_t *raiseInput_addr,
        uint8_t *reduceInput_addr)
: SimLinearSensor(value, timeStep),
    output_addr(output_addr),
    raiseInput_addr(raiseInput_addr),
    reduceInput_addr(reduceInput_addr) {

}

void SimSensorInPlc::loopCallback() {
    SimLinearSensor::loopCallback();
    if(*this->raiseInput_addr != 0){
        this->startRaise(3);
    }
    if(*this->reduceInput_addr != 0){
        this->startReduce(3);
    }
    *this->output_addr = this->get();       // 输出到plc内部D
}
